#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>

typedef long long ll;

const ll MOD = 998244353;
const int MAX = 3e6 + 5;

int n;
char s[MAX];

struct State {
	unsigned int length : 8;
	unsigned int str : 24;
	bool operator < (const State rhs) const {
		return (length | (str << 8)) < (rhs.length | (rhs.str << 8));
	}
	std::string toStr() const {
		std::string s;
		for(int i = 0; i < length; i++) {
			s += 'A' + (str >> i & 1);
		}
		return s;
	}
};

void solve1() {
	static std::set<State> tb;
	static std::queue<State> que;

	State org = {n, 0};
	for(int i = 1; i <= n; i++) {
		if(s[i])
			org.str |= 1 << (i - 1);
	}
	tb.insert(org);
	que.push(org);

	while(!que.empty()) {
		State cur = que.front();
		que.pop();
		
		for(int i = 0; i + 1 < cur.length; i++) {
			if((cur.str >> i & 3) == 2) continue;
			State stt = {
				cur.length - 2,
				(cur.str & ((1 << i) - 1)) | (cur.str >> (i + 2) << i)
			};
			if(tb.insert(stt).second) {
				que.push(stt);
			}
		}
	}

	printf("%d\n", (int)tb.size());
}

void solve2() {
	int ans = s[1] ? (n / 2 + 1) : ((n + 1) / 2);
	printf("%d\n", ans);
}

void solve0() {
	bool flag = true;

	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		s[i] -= 'A';
		if(i > 1 && s[i] == s[i - 1]) {
			flag = false;
		}
	}
	if(n <= 20) {
		solve1();
	}
	else if(flag) {
		solve2();
	}
}

#define USING_FILE_IO 1

int main() {
	#if USING_FILE_IO
	freopen("song.in", "r", stdin);
	freopen("song.out", "w", stdout);
	#endif
	solve0();
	fclose(stdin);
	fclose(stdout);
	return 0;
}